matlab <- readMat("put110.mat")
s0<-"100"
xmax<-200
par(mar=c(5.1,4.1,4.1,4.1))
pdf(file=paste("delta_put_",s0,"_xmax", xmax, ".pdf", sep=""))
start<-3
plot(matlab$S[start:length(matlab$S)],matlab$Delta,type="l",
	ylab="Delta", xlab="S", 
	main=paste("The Delta of a put option with underlying", s0, "with Xmax =", xmax), 
	sub="K = 110, volatility = 0.3, r = 0.04, dx = 0.005, dt = 0.001, T = 1")

par(new=T)
plot(matlab$S, matlab$vt[,1], col="red",type="l",axes=F,ylab="",xlab="")
lines(matlab$S, matlab$B,col="dark green")
axis(4, col="red")
mtext("Premium", side=4, line=3)

legend(110,40,c("Delta", "Premium", "Analytic result"), col=c("black","red", "dark green"), lty=c(1,1,1))
dev.off()

# Phi
pdf(file=paste("phi_put_",s0,".pdf", sep=""))
par(new=F)
par(mar=c(5.1,4.1,4.1,4.1))
plot(matlab$S,matlab$Phi,type="l",
	ylab="Phi", xlab="S", 
	main=paste("The Delta of a put option with underlying", s0),
	sub="K = 110, volatility = 0.3, r = 0.04, dx = 0.005, dt = 0.001, T = 1")

par(new=T)
plot(matlab$S, matlab$vt[,1], col="red",type="l",axes=F,ylab="",xlab="")
axis(4, col="red")
mtext("Premium", side=4, line=3)

legend(110,60,c("Premium", "Premium"), col=c("black","red"), lty=c(1,1))
dev.off()

# Gamma
pdf(file=paste("gamma_put_",s0,".pdf", sep=""))
start<-4
par(mar=c(5.1,4.1,4.1,4.1))
plot(matlab$S[start:length(matlab$S)],matlab$Gamma[2:length(matlab$Gamma)],type="l",
	ylab="Gamma", xlab="S", 
	main=paste("The Gamma of a put option with underlying", s0),
	sub="K = 110, volatility = 0.3, r = 0.04, dx = 0.005, dt = 0.001, T = 1")

par(new=T)
plot(matlab$S, matlab$vt[,1], col="red",type="l",axes=F,ylab="",xlab="")
axis(4, col="red")
mtext("Premium", side=4, line=3)

legend(110,30,c("Gamma", "Premium"), col=c("black","red"), lty=c(1,1))
dev.off()

# Vega
pdf(file=paste("vega_put_",s0,".pdf", sep=""))
par(mar=c(5.1,4.1,4.1,4.1))
plot(matlab$S,matlab$Vega,type="l",
	ylab="Vega", xlab="S", 
	main=paste("The Vega of a put option with underlying", s0),
	sub="K = 110, volatility = 0.3, r = 0.04, dx = 0.005, dt = 0.001, T = 1")

par(new=T)
plot(matlab$S, matlab$vt[,1], col="red",type="l",axes=F,ylab="",xlab="")
axis(4, col="red")
mtext("Premium", side=4, line=3)

legend(110,60,c("Vega", "Premium"), col=c("black","red"), lty=c(1,1))
dev.off()

# Rho
pdf(file=paste("rho_put_",s0,".pdf", sep=""))
par(mar=c(5.1,4.1,4.1,4.1))
plot(matlab$S,matlab$Rho,type="l",
	ylab="Rho", xlab="S", 
	main=paste("The Rho of a put option with underlying", s0),
	sub="K = 110, volatility = 0.3, r = 0.04, dx = 0.005, dt = 0.001, T = 1")

par(new=T)
plot(matlab$S, matlab$vt[,1], col="red",type="l",axes=F,ylab="",xlab="")
axis(4, col="red")
mtext("Premium", side=4, line=3)

legend(110,60,c("Rho", "Premium"), col=c("black","red"), lty=c(1,1))
dev.off()
